Skip to content

Conversation

@nuvw
Copy link
Contributor

@nuvw nuvw commented May 20, 2025

Untangles the keystrokes ctrl-h and backspace

Based on our discussion in #444, this seems to me like an obvious and simple change. But feel free to ignore it if you have any doubts (in particular since at some point in the past you felt the need to map the two keystrokes to the same Key; maybe there was a good reason for it after all).

Effectively, as I see it, this adds the possibility to define separate key bindings for ctrl_h and backspace in the config file, while not changing the default behavior of tiny at all.

Of course, there is now also the question of what action ctrl-h should be mapped to by default. But it seems to be standard to have it do the same as backspace, namely to delete the character before the cursor. At least I have checked that this is also the default behavior of vim, helix and the fish shell.

If you accept this PR, then I am not so sure about #444 anymore since (as you also point out in the discussion there) it taints libtiny_tui/src/key_map.rs with low-level knowledge about equality of certain key combinations for very little (and now even less) gain.

Before this commit, pressing either `ctrl-h` or `backspace` both
generated the same `Key::Backspace`, even though they send the distinct
bytes `8` and `127` to tiny. Now, they generate distinguishable events.

Also added a new default configuration for `Key::Ctrl('h')` so that the
default behavior of tiny remains precisely the same as before, but with
additional configurability of `ctrl_h` that is separate from `backspace`.
@osa1 osa1 merged commit d15ca06 into osa1:master May 20, 2025
6 of 7 checks passed
@osa1
Copy link
Owner

osa1 commented May 20, 2025

Thanks!

If you accept this PR, then I am not so sure about #444 anymore since (as you also point out in the discussion there) it taints libtiny_tui/src/key_map.rs with low-level knowledge about equality of certain key combinations for very little (and now even less) gain.

We can merge that as well, but we should update it now removing the ctrl-h part, and add comments to document why the special cases for i and [ are needed.

We should also not forget to update the CHANGELOG with the changes.

@nuvw
Copy link
Contributor Author

nuvw commented May 20, 2025

Sure. I can do that soon.

@nuvw nuvw deleted the untangle-backspace-ctrl_h branch May 20, 2025 12:52
osa1 pushed a commit that referenced this pull request May 21, 2025
* Added support for `ctrl_h` and `ctrl_i` in keymap config

Before this commit, having `ctrl_h` or `ctrl_i` in the keymap
configuration would define a mapping for `Key::Ctrl('h')` or
`Key::Ctrl('i')`, respectively. These two mappings would never trigger,
however, since the corresponding key strokes are represented as
`Key::Backspace` and `Key::Tab`. After the commit, `ctrl_h` and `ctrl_i`
effectively serve as synonyms of `backspace` and `tab`.

For consistency, also added support for `ctrl_[` as a synonym of `esc`.

* Add explanation for special treatment of `ctrl_i` and `ctrl_[`

* Update CHANGELOG (#444, #445)

* Moved recent changes to new Unreleased section in CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants